package com.nlp.visualization.controller.spring.controller;

import com.nlp.visualization.common.CONSTANTS;
import com.nlp.visualization.pojo.common.AjaxReturn;
import com.nlp.visualization.service.weibo_mine.IWeiboContentMod0Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author LXM
 * @Title: NLPVisualizationTools
 * @Description:
 * @date 2018/5/19上午10:07
 */
@Controller
@RequestMapping("/weiboDetail")
public class WeiboDeatilController {

    @Autowired
    private IWeiboContentMod0Service contentMod0Service;


    @RequestMapping("/all")
    @ResponseBody
    public AjaxReturn getAllWeibo() {

        List list = contentMod0Service.findAll();
        return new AjaxReturn(CONSTANTS.ERROR_SUCCESS, "成功", list);

    }


    @RequestMapping("/delete")
    @ResponseBody
    public AjaxReturn deleteContentById(HttpServletRequest request) {
        String id = Integer.parseInt(request.getParameter("id")) + "";

        try {
            contentMod0Service.deleteById(id);
            return new AjaxReturn(CONSTANTS.ERROR_SUCCESS, "成功");
        } catch (Exception e) {
            return new AjaxReturn(CONSTANTS.ERROR_UNKNOWN, "删除失败");
        }
    }


}
